package person

import (
	"fmt"
)

type Person struct {
	Name        string
	pswd        string
	MoneyPacket float32
	Points      int
}

func (p *Person) Xiaofei() {
	fmt.Println(p.Name, "正在消费")
	fmt.Println("消费项目，1.专辑小卡（随机一张） 2.p版DREAM SCAPE 3.个人单封")
	if p.MoneyPacket < 20 {
		fmt.Println("请检查余额")
		return
	}
	var xiangmu int
	fmt.Scanln(&xiangmu)
	switch xiangmu {
	case 1:
		if p.MoneyPacket < 20 {
			fmt.Println("购买专辑小卡（随机一张）余额不足")
			return
		}
		p.MoneyPacket = p.MoneyPacket - 20
		p.Points = p.Points + 20
		fmt.Println(p.Name, "消费完余额为:", p.MoneyPacket, "积分", p.Points)
	case 2:
		if p.MoneyPacket < 30 {
			fmt.Println("请检查余额")
			return
		}
		p.MoneyPacket = p.MoneyPacket - 30
		p.Points = p.Points + 30
		fmt.Println(p.Name, "消费完余额为:", p.MoneyPacket, "积分", p.Points)
	case 3:
		if p.MoneyPacket < 100 {
			fmt.Println("请检查余额")
			return
		}
		p.MoneyPacket = p.MoneyPacket - 100
		p.Points = p.Points + 100
		fmt.Println(p.Name, "消费完余额为:", p.MoneyPacket, "积分", p.Points)
	default:
		fmt.Println("无该项目")
	}
}

func (p *Person) Jifen() {
	fmt.Println(p.Name, "查看积分", p.Points)
}

func (p *Person) AddPoints(points int) {
	p.Points = p.Points + points
}

func (p *Person) Chongzhi() {
	fmt.Println(p.Name, "正在充值")
	fmt.Println("请输入")
	var input float32
	fmt.Scanln(&input)
	p.MoneyPacket = p.MoneyPacket + input
	fmt.Println("充值完成，余额为:", p.MoneyPacket)
}

func (p *Person) Login() bool {
	var pswd string
	fmt.Println("输入密码")
	fmt.Scanln(&pswd)

	if pswd == "123456" {
		p.Name = "NCT"
		return true
	} else {
		return false
	}
}

func (p *Person) UsePoints() {
	fmt.Println(p.Name, "正在使用积分")
	var pointsToUse int
	fmt.Println("请输入要使用的积分数量")
	fmt.Scanln(&pointsToUse)
	if pointsToUse > p.Points {
		fmt.Println("积分不足")
		return
	}
	p.Points = p.Points - pointsToUse
	fmt.Println(p.Name, "使用积分后剩余积分为:", p.Points)
}
